﻿using DG.Tweening;
using System;
using System.Collections;
using System.Threading.Tasks;
using UnityEngine;

namespace UnityEngine.UnityVideoPlayer
{
    public enum FSMode
    { 
        FullSceneInBehind=-1,
        NoFullScene = 0,
        FullSceneInFront = 1,
    }

    public abstract class AbstractTemplate
    {
        /// <summary>
        /// 是否允许全屏。
        /// </summary>
        public virtual bool EnableSwitchFSMode { get; } = false; 

        /// <summary>
        /// 是否在全屏模式
        /// </summary>
        public bool IsInFSMode { get; protected set; }

        public FSMode fSMode { get; protected set; } = FSMode.FullSceneInBehind;

        public virtual void FullScreenInFront(RectTransform fsContentContainer, RectTransform fsExUIContainer)
        {
            if (!EnableSwitchFSMode)
                return;

            IsInFSMode = true;

            fSMode = FSMode.FullSceneInFront;

            //content.SetParent(fsContentContainer);

            //SetParentPlane(content, fsContentContainer);
        }

        public virtual void FullScreenInBehind(RectTransform contentContainer, RectTransform fsExUIContainer)
        {
            Debug.Log("FullScreenInBehind");
            if (!EnableSwitchFSMode)
                return;

            IsInFSMode = true;

            fSMode = FSMode.FullSceneInBehind;

            //content.SetParent(contentContainer);

            //SetParentPlane(content, contentContainer);
        }

        public virtual void NonFullScreen(RectTransform nonfsContentContainer, RectTransform exUIContainer)
        {
            Debug.Log("NonFullScreen");

            IsInFSMode = false;

            fSMode = FSMode.NoFullScene;

            //content.SetParent(nonfsContentContainer);

            //SetParentPlane(content, nonfsContentContainer);
        }
       
        protected virtual void SetParentPlane(RectTransform cPlane, RectTransform pPlane)
        {
            cPlane.SetParent(pPlane);
              
            cPlane.localPosition = Vector3.zero;

            cPlane.localScale = Vector3.one;
             
            cPlane.offsetMin = Vector2.zero;

            cPlane.offsetMax = Vector2.zero;
        }
    }
}